package com.actionpals.components.controls.calendar
{
	import flash.display.DisplayObject;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.text.TextFormat;
	
	public class CalendarStyle
	{
		private var _backgroundAlpha:Number = 1;
		private var _backgroundColor:uint = 0xFFFFFF;
		private var _borderColor:uint = 0xAAB3B3;
		private var _borderThickness:Number = 1;
		private var _cornerRadius:Number = 8;
		private var _dayHorizontalGap:Number = 2;
		private var _dayVerticalGap:Number = 0;
		private var _footerPercentHeight:Number = 0;
		
		private var _nextMonthButton:DisplayObject;
		private var _previousMonthButton:DisplayObject;
		
		private var _dateHeaderStyle:CalendarHeaderStyle;
		private var _dayNameHeaderStyle:CalendarHeaderStyle;
		private var _dayStyle:CalendarDateStyle;
		private var _eventStyle:CalendarDateStyle;
		private var _todayStyle:CalendarDateStyle;
		private var _todayEventStyle:CalendarDateStyle;
		
		public function CalendarStyle()
		{
			initStyles();
			createMonthButtons();
		}
		
		public function get backgroundAlpha():Number
		{
			return _backgroundAlpha;
		}
		public function set backgroundAlpha( value:Number ):void
		{
			_backgroundAlpha = value;
		}
		
		public function get backgroundColor():uint
		{
			return _backgroundColor;
		}
		public function set backgroundColor( value:uint ):void
		{
			_backgroundColor = value;
		}
		
		public function get borderColor():uint
		{
			return _borderColor;
		}
		public function set borderColor( value:uint ):void
		{
			_borderColor = value;
		}
		
		public function get borderThickness():Number
		{
			return _borderThickness;
		}
		public function set borderThickness( value:Number ):void
		{
			_borderThickness = value;
		}
		
		public function get cornerRadius():Number
		{
			return _cornerRadius;
		}
		public function set cornerRadius( value:Number ):void
		{
			_cornerRadius = value;
		}
		
		public function get dayHorizontalGap():Number
		{
			return _dayHorizontalGap;
		}
		public function set dayHorizontalGap( value:Number ):void
		{
			_dayHorizontalGap = value;
		}
		
		public function get dayVerticalGap():Number
		{
			return _dayVerticalGap;
		}
		public function set dayVerticalGap( value:Number ):void
		{
			_dayVerticalGap = value;
		}
		
		public function get footerPercentHeight():Number
		{
			return _footerPercentHeight;
		}
		public function set footerPercentHeight( value:Number ):void
		{
			_footerPercentHeight = value;
		}
		
		
		public function get nextMonthButton():DisplayObject
		{
			return _nextMonthButton;
		}
		public function set nextMonthButton( value:DisplayObject ):void
		{
			_nextMonthButton = value;
		}
		
		public function get previousMonthButton():DisplayObject
		{
			return _previousMonthButton;
		}
		public function set previousMonthButton( value:DisplayObject ):void
		{
			_previousMonthButton = value;
		}
		
		
		public function get dateHeaderStyle():CalendarHeaderStyle
		{
			return _dateHeaderStyle;
		}
		public function set dateHeaderStyle( value:CalendarHeaderStyle ):void
		{
			_dateHeaderStyle = value;
		}
		
		public function get dayNameHeaderStyle():CalendarHeaderStyle
		{
			return _dayNameHeaderStyle;
		}
		public function set dayNameHeaderStyle( value:CalendarHeaderStyle ):void
		{
			_dayNameHeaderStyle = value;
		}
		
		public function get dayStyle():CalendarDateStyle
		{
			return _dayStyle;
		}
		public function set dayStyle( value:CalendarDateStyle ):void
		{
			_dayStyle = value;
		}
		
		public function get eventStyle():CalendarDateStyle
		{
			return _eventStyle;
		}
		public function set eventStyle( value:CalendarDateStyle ):void
		{
			_eventStyle = value;
		}
		
		public function get todayStyle():CalendarDateStyle
		{
			return _todayStyle;
		}
		public function set todayStyle( value:CalendarDateStyle ):void
		{
			_todayStyle = value;
		}
		
		public function get todayEventStyle():CalendarDateStyle
		{
			return _todayEventStyle;
		}
		public function set todayEventStyle( value:CalendarDateStyle ):void
		{
			_todayEventStyle = value;
		}
		
		
		private function initStyles():void
		{
			var dateHeaderTextFormat:TextFormat = new TextFormat( "sans-serif", 18, 0x000000, true );
			dateHeaderStyle = new CalendarHeaderStyle( dateHeaderTextFormat, false, 14, [ 0xE1E5EB, 0XF4F5F7 ], [ 1, 1 ], 0xAAB3B3, 1, 1 );
			
			var dayNameHeaderTextFormat:TextFormat = new TextFormat( "sans-serif", 18, 0x000000, true );
			dayNameHeaderStyle = new CalendarHeaderStyle( dayNameHeaderTextFormat, false, 12, [ 0xE1E5EB, 0XF4F5F7 ], [ 0, 0 ] );
			
			var dayTextFormat:TextFormat = new TextFormat( "sans-serif", 12, 0x333333, true );
			var dayUpState:CalendarDateStateStyle = new CalendarDateStateStyle( dayTextFormat );
			var dayOverState:CalendarDateStateStyle = dayUpState.clone();
			dayOverState.color = 0xCDCDCD;
			var daySelectedState:CalendarDateStateStyle = dayOverState.clone();
			var dayVisitedUpState:CalendarDateStateStyle = dayUpState.clone();
			dayVisitedUpState.color = 0xDDDDDD;
			var dayVisitedOverState:CalendarDateStateStyle = dayOverState.clone();
			dayStyle = new CalendarDateStyle( dayUpState, dayOverState, daySelectedState, dayVisitedUpState, dayVisitedOverState );
			
			var eventTextFormat:TextFormat = new TextFormat( "sans-serif", 12, 0xFFFFFF, true );
			var eventUpState:CalendarDateStateStyle = new CalendarDateStateStyle( eventTextFormat, false, 0x818181 );
			var eventOverState:CalendarDateStateStyle = eventUpState.clone();
			eventOverState.color = 0x95A8B4;
			var eventSelectedState:CalendarDateStateStyle = eventOverState.clone();
			var eventVisitedUpState:CalendarDateStateStyle = eventUpState.clone();
			eventVisitedUpState.color = 0xAAC0CD;
			var eventVisitedOverState:CalendarDateStateStyle = eventOverState.clone();
			eventStyle = new CalendarDateStyle( eventUpState, eventOverState, eventSelectedState, eventVisitedUpState, eventVisitedOverState );
			
			var todayTextFormat:TextFormat = new TextFormat( "sans-serif", 12, 0x333333, true );
			var todayUpState:CalendarDateStateStyle = new CalendarDateStateStyle( todayTextFormat, false, 0xFFFFFF, 1, 0xB2E1FF, 1, 2 );
			var todayOverState:CalendarDateStateStyle = todayUpState.clone();
			todayOverState.color = 0xCDCDCD;
			var todaySelectedState:CalendarDateStateStyle = todayOverState.clone();
			var todayVisitedUpState:CalendarDateStateStyle = todayUpState.clone();
			todayVisitedUpState.color = 0xDDDDDD;
			var todayVisitedOverState:CalendarDateStateStyle = todayOverState.clone();
			todayStyle = new CalendarDateStyle( todayUpState, todayOverState, todaySelectedState, todayVisitedUpState, todayVisitedOverState );
			
			var todayEventTextFormat:TextFormat = new TextFormat( "sans-serif", 12, 0xFFFFFF, true );
			var todayEventUpState:CalendarDateStateStyle = new CalendarDateStateStyle( todayEventTextFormat, false, 0x818181, 1, 0xB2E1FF, 1, 2 );
			var todayEventOverState:CalendarDateStateStyle = todayEventUpState.clone();
			todayEventOverState.color = 0x95A8B4;
			var todayEventSelectedState:CalendarDateStateStyle = todayEventOverState.clone();
			var todayEventVisitedUpState:CalendarDateStateStyle = todayEventUpState.clone();
			todayEventVisitedUpState.color = 0xAAC0CD;
			var todayEventVisitedOverState:CalendarDateStateStyle = todayEventOverState.clone();
			todayEventStyle = new CalendarDateStyle( todayEventUpState, todayEventOverState, todayEventSelectedState, todayEventVisitedUpState, todayEventVisitedOverState );
		}
		
		private function createMonthButtons():void
		{
			var arrowSize:Number = 10;
			var arrowColor:uint = 0xAAAAAA;
			var arrowBorderColor:uint = 0xCCCCCC;
			
			var arrowLeft:Shape = new Shape();
			arrowLeft.graphics.beginFill( arrowColor );
			arrowLeft.graphics.lineStyle( 1, arrowBorderColor, 1 );
			arrowLeft.graphics.moveTo( 0, arrowSize/2 );
			arrowLeft.graphics.lineTo( arrowSize, 0 );
			arrowLeft.graphics.lineTo( arrowSize, arrowSize );
			arrowLeft.graphics.lineTo( 0, arrowSize/2 );
			arrowLeft.graphics.endFill();
			_previousMonthButton = new Sprite();
			Sprite( _previousMonthButton ).addChild( arrowLeft );
			
			var arrowRight:Shape = new Shape();
			arrowRight.graphics.beginFill( arrowColor );
			arrowRight.graphics.lineStyle( 1, arrowBorderColor, 1 );
			arrowRight.graphics.moveTo( arrowSize, arrowSize/2 );
			arrowRight.graphics.lineTo( 0, 0 );
			arrowRight.graphics.lineTo( 0, arrowSize );
			arrowRight.graphics.lineTo( arrowSize, arrowSize/2 );
			arrowRight.graphics.endFill();
			_nextMonthButton = new Sprite();
			_nextMonthButton.name = "next";
			Sprite( _nextMonthButton ).addChild( arrowRight );
		}
		
	}
}